import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
let classmateArr = []
if(sessionStorage.getItem('classmateArr')){
  classmateArr = JSON.parse(sessionStorage.getItem('classmateArr'))
} //给原始赋值

const store = new Vuex.Store({
  state: {
    classmateArr:classmateArr,
  },
  mutations:{
    add(state,paramsArr){
      state.classmateArr = paramsArr
      sessionStorage.setItem('classmateArr',JSON.stringify(paramsArr))
    },
    delete(state,params){
      state.classmateArr.splice(params,1)
      sessionStorage.setItem('classmateArr',JSON.stringify(state.classmateArr))
    }
  },
})
export default store
